import java.util.HashMap;
import java.util.Map;

public class LongGet {
    public int lengthOfLongestSubstring(String s) {

        Map<Character,Integer> map = new HashMap<Character,Integer>();

        int n = s.length();
        int max = 0;

        for(int stat = 0, end = 0;end < n;end++) {
            char tmp = s.charAt(end);
            if (map.containsKey(tmp)) {
                stat = Math.max(map.get(tmp),stat);
                System.out.println(map.get(tmp));
            }
            max = Math.max(stat,max);
            map.put(tmp,end+1);
        }
        return max;
    }

}
